#ifndef RNGLIB_H
#define RNGLIB_H


#include"stdint.h"


  typedef struct
  {
      int pToBuf;		/* offset from start of buffer where to write next */
      int pFromBuf;	/* offset from start of buffer where to read next */
      int bufSize;	/* size of ring in bytes */
      char *buf;
  }rng;
  typedef  rng* RING_ID;
    /*!
     * \brief <+description of block+>
     * \ingroup beklBlk
     *
     */
  
        char * bcopy(const char *src, char *dest, int count);
        void    rngFlush (RING_ID rngBuf);

        void    rngDelete(RING_ID rngBuf);

        int     rngBufGet(
          RING_ID rngBuf,
                char *buffer,               /* pointer to buffer to receive data */
                int maxbytes                /* maximum number of bytes to get    */
                );

         RING_ID rngCreate(int nbytes  );

        int rngBufPut (RING_ID rngBuf,
        char *buffer,               /* buffer to get data from       */
         int nbytes                   /* number of bytes to try to put */
         );

        int rngIsEmpty(RING_ID rngBuf);

        int rngIsFull(RING_ID rngBuf);

        int rngNBytes(RING_ID rngBuf);


        void rngPutAhead( 
          RING_ID rngBuf,
          char byte,             /* byte to be put in ring        */
            int offset             /* offset beyond next input byte where to put byte */
        );

        void rngMoveAhead
        (
          RING_ID rngBuf,
         int n            /* number of bytes ahead to move input pointer */
        );

        int rngBufGetNoDel ( RING_ID rngBuf,char *buffer, int maxbytes);

        void rngMoveRead
        (
          RING_ID rngBuf,
         int n            /* number of bytes ahead to move input pointer */
        );
     
     // 新增：模式查找函数
     int rngFindPattern(RING_ID rngBuf, const char *pattern, int patternLen);
     int rngFindTextPattern(RING_ID rngBuf, const char *pattern);
     int rngGetDataFromPos(RING_ID rngBuf, char *buffer, int startPos, int maxBytes);
     void rngRemoveDataUpTo(RING_ID rngBuf, int pos);
     


#endif // RINGBUFFER_H
